async = require 'async'


# async waterfall
async.waterfall([
  ((callback)->
        callback null,3      #callback must be called
  ),
  (
    (a,callback)->            #a refer 3 in the first function
      callback null,a+1
  ),
  (
    (a,callback)->
      callback new Error('wrong'),a+1    # err stop the flow
  )


],
  (err,a)->
    if err
      console.log err
    else
      console.log a

)